<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" lang="zh" class="no-js">
<head th:include="common_include :: commonHead('邮件服务器管理')"/>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>邮件服务器管理</h5>
                </div>
                <div class="ibox-content">
                    <div class="row row-lg">
                        <div class="col-sm-12">
                            <div class="row">
                                <form id="query-form">
                                    <div class="col-sm-5">
                                        <div class="input-group m-b">
                                            <span class="input-group-addon">服务器名称</span>
                                            <input type="text" name="serverName" id="serverName"
                                                   class="form-control" placeholder="服务器名称">
                                        </div>
                                    </div>
                                    <div class="col-sm-5">
                                        <div class="input-group m-b">
                                            <span class="input-group-addon">服务器主机</span>
                                            <input type="text" name="emailHost" id="emailHost"
                                                   class="form-control" placeholder="服务器主机">
                                        </div>
                                    </div>
                                    <div class="col-sm-2">
                                        <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                                class="fa fa-search"></i>&nbsp;搜索</a>
                                    </div>
                                </form>
                            </div>
                            <div class="btn-group hidden-xs" id="toolbar" role="group">
                                <a class="btn btn-outline btn-warning btn-rounded"
                                   th:if="${@permission.hasPermission('email:server:import')}"
                                   onclick="$.table.importExcel()"><i
                                        class="fa fa-file-o"></i> 导入</a>
                                <a class="btn btn-outline btn-success btn-rounded"
                                   th:if="${@permission.hasPermission('email:server:add')}"
                                   onclick="$.operate.add(0)"><i
                                        class="fa fa-plus"></i> 新增</a>
                                <a class="btn btn-outline btn-info btn-rounded"
                                   th:if="${@permission.hasPermission('email:server:export')}"
                                   onclick="$.table.exportExcel()"><i
                                        class="fa fa-file-excel-o"></i> 导出</a>
                                <a class="btn btn-outline btn-danger btn-rounded"
                                   th:if="${@permission.hasPermission('email:server:delete')}"
                                   onclick="$.operate.batRemove()"><i
                                        class="fa fa-trash-o"></i> 删除</a>
                            </div>
                            <div class="col-sm-12 select-info table-striped">
                                <table id="bootstrap-table" data-mobile-responsive="true"></table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<form th:include="common_include :: importForm" id="importForm" enctype="multipart/form-data" class="form-horizontal m" style="display: none;"/>
</body>
<div th:include="common_include :: commonFoot"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.displayWithPermission('email:server:edit')}]];
    var deleteFlag = [[${@permission.displayWithPermission('email:server:delete')}]];
    var protocolTypes = [[${@dictCode.selectDictCodeByType('eds_email_protocoltype')}]];
    var prefix = ctx + "service/email/server";
    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/delete",
            exportUrl: prefix + "/export",
            importTemplateUrl: prefix + "/importTemplate",
            importUrl: prefix + "/import",
            modalName: "邮件服务器",
            search: false,
            showExport: false,
            columns: [{
                checkbox: true
            }, {
                field: 'rowKey',
                title: '主键ID',
                sortable: true,
                visible: false
            }, {
                field: 'serverName',
                title: '服务器名称',
                sortable: true
            }, {
                field: 'emailProtocol',
                title: '邮件协议',
                sortable: true,
                formatter: function (value, row, index) {
                    return $.table.selectDictName(protocolTypes, value);
                }
            }, {
                field: 'emailHost',
                title: '服务器主机',
                sortable: true
            }, {
                field: 'emailPort',
                title: '服务器端口',
                sortable: true
            }, {
                title: '操作',
                align: 'center',
                formatter: function (value, row, index) {
                    var actions = [];
                    actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.rowKey + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                    actions.push('<a class="btn btn-danger btn-xs ' + deleteFlag + '" href="#" onclick="$.operate.remove(\'' + row.rowKey + '\')"><i class="fa fa-remove"></i>删除</a>');
                    return actions.join('');
                }
            }]
        };
        $.table.init(options);
    });
</script>
</html>